Also turn it into a readable, construct-only property.
Every GDK object should have this. (Apart from GdkDisplay, obviously.)
gdk_drag_status
gdk_drag_drop_succeeded
+gdk_drag_context_get_display
gdk_drag_context_get_actions
gdk_drag_context_get_suggested_action
gdk_drag_context_get_selected_action
g_return_val_if_fail (GDK_WINDOW_IS_BROADWAY (window), NULL);
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
+ "display", gdk_window_get_display (window),
NULL);
- new_context->display = gdk_window_get_display (window);
return new_context;
}
{ 0, "dnd-none", NULL },
};
+enum {
+ PROP_0,
+ PROP_DISPLAY,
+ N_PROPERTIES
+};
+
enum {
CANCEL,
DROP_PERFORMED,
N_SIGNALS
};
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static guint signals[N_SIGNALS] = { 0 };
static GList *contexts = NULL;
* the GTK+ documentation for more information.
*/
+/**
+ * gdk_drag_context_get_display:
+ * @context: a #GdkDragContext
+ *
+ * Gets the #GdkDisplay that the drag context was created for.
+ *
+ * Returns: (transfer none): a #GdkDisplay
+ **/
+GdkDisplay *
+gdk_drag_context_get_display (GdkDragContext *context)
+{
+ return context->display;
+}
+
/**
* gdk_drag_context_get_formats:
* @context: a #GdkDragContext
contexts = g_list_prepend (contexts, context);
}
+static void
+gdk_drag_context_set_property (GObject *gobject,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
+
+ switch (prop_id)
+ {
+ case PROP_DISPLAY:
+ context->display = g_value_get_object (value);
+ g_assert (context->display != NULL);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdk_drag_context_get_property (GObject *gobject,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
+
+ switch (prop_id)
+ {
+ case PROP_DISPLAY:
+ g_value_set_object (value, context->display);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ break;
+ }
+}
+
static void
gdk_drag_context_finalize (GObject *object)
{
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = gdk_drag_context_get_property;
+ object_class->set_property = gdk_drag_context_set_property;
object_class->finalize = gdk_drag_context_finalize;
+ /**
+ * GdkDragContext:display:
+ *
+ * The #GdkDisplay that the drag context belongs to.
+ *
+ * Since: 3.94
+ */
+ properties[PROP_DISPLAY] =
+ g_param_spec_object ("display",
+ "Display",
+ "Display owning this clipboard",
+ GDK_TYPE_DISPLAY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY);
+
/**
* GdkDragContext::cancel:
* @context: The object on which the signal is emitted
NULL, NULL,
g_cclosure_marshal_VOID__FLAGS,
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
/*
GDK_AVAILABLE_IN_ALL
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
+GDK_AVAILABLE_IN_3_94
+GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
void gdk_drag_context_set_device (GdkDragContext *context,
GdkDevice *device);
/* Create fake context */
_gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
+ "display", display,
NULL);
- _gdk_quartz_drag_source_context->display = gdk_window_get_display (window);
_gdk_quartz_drag_source_context->is_source = TRUE;
_gdk_quartz_drag_source_context->source_window = window;
const char *const *mimetypes;
gsize i, n_mimetypes;
- context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
+ context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
+ "display", gdk_window_get_display (window),
+ NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
- context->display = gdk_window_get_display (window);
context->source_window = g_object_ref (window);
context->is_source = TRUE;
context->formats = gdk_content_formats_ref (formats);
GdkWaylandDragContext *context_wayland;
GdkDragContext *context;
- context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
+ context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
+ "display", display,
+ NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
- context->display = display;
context->is_source = FALSE;
context->formats = gdk_content_formats_new (NULL, 0);
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
GdkDragContext *context;
- context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT, NULL);
+ context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
+ "display", display,
+ NULL);
context = GDK_DRAG_CONTEXT(context_win32);
- context->display = display;
gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
g_object_unref (context);
}
-
-static GdkDisplay *
-gdk_drag_context_get_display (GdkDragContext *context)
-{
- if (context->source_window)
- return GDK_WINDOW_DISPLAY (context->source_window);
- else if (context->dest_window)
- return GDK_WINDOW_DISPLAY (context->dest_window);
-
- g_assert_not_reached ();
- return NULL;
-}
-
static void
send_client_message_async (GdkDragContext *context,
Window window,
display_x11->current_dest_drag = NULL;
}
- context_x11 = (GdkX11DragContext *)g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
+ context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
+ "display", display,
+ NULL);
context = (GdkDragContext *)context_x11;
- context->display = display;
context->protocol = GDK_DRAG_PROTO_XDND;
context_x11->version = version;
{
GdkDragContext *context;
- context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
+ context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
+ "display", gdk_window_get_display (window),
+ NULL);
- context->display = gdk_window_get_display (window);
context->is_source = TRUE;
context->source_window = window;
g_object_ref (window);